#include<iostream>
#include<string>
#include<vector>
#include "../UserInfo.hpp"
using namespace db;

void Unity1(UserInfo& ctl,Json::Value& user)
{
    user["username"] = "昨夜微凉";
    user["password"] = "12345678";
    ctl.Insert(user);
    std::string str;
    util::JsonTool::Serialization(user,&str);
    std::cout<<"用户:"<<str<<"新增成功"<<std::endl;
}
void Unity2(UserInfo& ctl,Json::Value& user)
{
    user["username"] = "昨夜微凉";
    user["password"] = "12345678";
    ctl.Login(user);
    std::string str;
    util::JsonTool::Serialization(user,&str);
    std::cout<<str<<std::endl;
}
void Unity3(UserInfo& ctl,Json::Value& user)
{
    ctl.FindUser("昨夜微凉",user);
    std::string str;
    util::JsonTool::Serialization(user,&str);
    std::cout<<str<<std::endl;
}
void Unity4(UserInfo& ctl,Json::Value& user)
{
    ctl.FindUser(3,user);
    std::string str;
    util::JsonTool::Serialization(user,&str);
    std::cout<<str<<std::endl;
}
void Unity5(UserInfo& ctl,Json::Value& user)
{
    ctl.AddScoreAndCnt(3,50);
    ctl.ReduceScore(3,10);
    ctl.FindUser(3,user);
    std::string str;
    util::JsonTool::Serialization(user,&str);
    std::cout<<str<<std::endl;
}
int main()
{
    UserInfo ctl("127.0.0.1","con","123456","lhd_work_db");
    Json::Value user;
    //Unity1(ctl,user);
    //Unity2(ctl,user);
    // Unity3(ctl,user);
    // Unity4(ctl,user);
    Unity5(ctl,user);
    return 0;
}